package com.allwees.bs.module.fms.entity;

import com.allwees.bs.core.modelbase.entity.BaseEntity;
import com.allwees.bs.module.fms.constant.EAccountLogBsType;
import com.allwees.bs.module.fms.constant.EBalanceType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 账务流水基类
 *
 * @author yangylsky
 * @since 2019-12-31
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public abstract class BaseAccountLog extends BaseEntity {
    @Column(length = 48)
    private String branchUuid;

    /**
     * 收支类型
     */
    private EBalanceType balanceType;

    /**
     * 账务流水类型
     */
    private EAccountLogBsType bsType;

    /**
     * 流水号
     */
    @Column(length = 32)
    private String no;

    /**
     * 本方帐号uuid
     */
    @Column(length = 48)
    private String accountUuid;

    /**
     * 本方帐号
     */
    @Column(length = 32)
    private String accountNo;

    /**
     * 对方帐号uuid
     */
    @Column(length = 48)
    private String counterpartyAccountUuid;

    /**
     * 对方帐号
     */
    @Column(length = 32)
    private String counterpartyAccountNo;

    /**
     * 交易完成时间
     */
    private Date completedAt;

    /**
     * 发生金额
     */
    @Column(precision = 8, scale = 2)
    private BigDecimal takeAmount;

    /**
     * 手续费
     */
    @Column(precision = 8, scale = 2)
    private BigDecimal fee;


    /**
     * 佣金
     */
    @Column(precision = 8, scale = 2)
    private BigDecimal commission;


    /**
     * 汇率
     */
    @Column(precision = 5, scale = 4)
    private BigDecimal exchangeRate;

    /**
     * 实际到账(人民币)
     */
    @Column(precision = 8, scale = 2)
    private BigDecimal actualAmt;


    private Integer accountType;


    /**
     * 实际到账(美元)
     */
    @Column(precision = 8, scale = 2)
    private BigDecimal actualAmtUsd;

    /**
     * 提现账户
     */
    @Column(length = 32)
    private String bankAccountNo;


    /**
     * 收款银行
     */
    @Column(length = 200)
    private String bankName;

    /**
     * 审核时间
     */
    @Column
    private Date auditTime;


    /**
     * 金额币种
     */
    @Column(length = 4)
    private String currency;

    /**
     * 操作后余额
     */
    @Column(precision = 8, scale = 2)
    private BigDecimal balance;


    /**
     * 操作后已结算金额
     */
    @Column(precision = 8, scale = 2)
    private BigDecimal settledAmount;

    /**
     * 余额币种
     */
    @Column(length = 4)
    private String balanceCurrency;

    /**
     * 备注
     */
    @Column(length = 512)
    private String comment;

    public String getBalanceTypeDesc() {
        return balanceType.desc();
    }

    public String getBsTypeDesc() {
        return bsType.desc();
    }
}
